package com.example.xianji.adapter;

import java.util.ArrayList;

import com.example.xianji.R;
import com.example.xianji.bean.TiWen;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class TiWen_Adapter extends BaseAdapter {
    private Context mContext;
    private ArrayList<TiWen> list;

    public TiWen_Adapter(Context mContext, ArrayList<TiWen> list) {
        super();
        this.mContext = mContext;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int arg0) {
        return arg0;
    }

    @Override
    public long getItemId(int arg0) {
        return arg0;
    }

    @Override
    public View getView(int arg0, View arg1, ViewGroup arg2) {
        Holder mHolder;
        if (arg1 == null) {
            mHolder = new Holder();
            arg1 = View.inflate(mContext, R.layout.tiwen_listview_item, null);
            mHolder.replay_contant = (TextView) arg1.findViewById(R.id.replay_contant);
            mHolder.tiwen_contant = (TextView) arg1.findViewById(R.id.tiwen_contant);
            mHolder.tiwen_nickname = (TextView) arg1.findViewById(R.id.tiwen_nickname);
            arg1.setTag(mHolder);
        }
        mHolder = (Holder) arg1.getTag();
        mHolder.replay_contant.setText("回复: " + list.get(arg0).getDetail());
        mHolder.tiwen_contant.setText(list.get(arg0).getQuery());
        mHolder.tiwen_nickname.setText(list.get(arg0).getNickname());
        return arg1;
    }

    class Holder {
        TextView tiwen_contant;
        TextView replay_contant;
        TextView tiwen_nickname;
    }
}
